% 一种书籍的风格，对中文处理较好。
%
% by wanze
% LPPL LaTeX Public Project License
%
%

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{teachingplan}

%宏包编写基本命令。
%\def\hi{Hello, this is my own package}
%\let\myDate\date
%\newcommand\GoodBye[1][\bfseries]{{#1Good Bye}}




%========基本必备的宏包========%
\RequirePackage{calc,float,multicol,moresize}
%\RequirePackage[onehalfspacing]{setspace}
\linespread{1.4}
%1.3 onehalfspacing
%试卷或需要文字紧凑的
%1.6 doublespacing

%=========其他命令==========%
\newcommand{\notefont}{\ttfamily\fontsize{10pt}{10pt}\selectfont }


%=========页面设置=========%
\RequirePackage[a4paper, %a4paper size 297:210 mm
  bindingoffset=10mm,%裝訂線
  top=35mm,  %上邊距 包括頁眉
  bottom=30mm,%下邊距 包括頁腳
  inner=10mm,  %左邊距or inner
  outer=10mm,  %右邊距or  outer
  headheight=20mm,%頁眉
  headsep=10mm,%
  footskip=15mm,%
  marginparsep=10pt, %旁註與正文間距
  marginparwidth=75pt,includemp=true% 旁註寬度計入width%旁註寬度
  ]{geometry}


%  reversemarginpar,%oneside旁注
%  asymmetric


%color
\RequirePackage[table]{xcolor}
\definecolor{bgcolor-0}{HTML}{CCFFCC}


%================字體================%
%设置数学字体
\RequirePackage{amssymb,amsmath}
\RequirePackage{fontspec}
%si unit
\RequirePackage{siunitx}
\sisetup{
math-micro = \text{μ},
text-micro = μ
}
%num命令两边加上空格 numb
\providecommand{\numb}[1]{{ \num{#1} }}


\providecommand{\abs}[1]{\lvert#1\rvert}
\everymath{\displaystyle}

 %設置英文字體
\setmainfont[Mapping=tex-text]{DejaVu Serif}
\setsansfont[Mapping=tex-text]{DejaVu Sans}
\setmonofont[Mapping=tex-text]{DejaVu Sans Mono}

%中文環境
\RequirePackage[CJKnumber=true]{xeCJK}
\xeCJKsetup{PunctStyle=plain}
\setCJKmainfont[BoldFont=Adobe 黑体 Std,ItalicFont=Adobe 楷体 Std]
    {Adobe 宋体 Std}%影響rmfamily字體
\setCJKsansfont{Adobe 黑体 Std}%影響sffamily字體
\setCJKmonofont{Adobe 楷体 Std}%影響ttfamily字體

\RequirePackage{xltxtra} %put here to avoid some package option error. maybe this package is useless ?

%=============新的字符===========%
\newfontfamily{\libertine}[Scale=1.3]{Linux Libertine O}
\newfontfamily{\ubuntu}[Scale=3]{Ubuntu}
\RequirePackage{newunicodechar}
\newunicodechar{Ⓐ}{{\libertine{Ⓐ}}}
\newunicodechar{Ⓑ}{{\libertine{Ⓑ}}}
\newunicodechar{Ⓒ}{{\libertine{Ⓒ}}}
\newunicodechar{Ⓓ}{{\libertine{Ⓓ}}}
\newunicodechar{①}{{\libertine{①}}}
\newunicodechar{②}{{\libertine{②}}}
\newunicodechar{③}{{\libertine{③}}}
\newunicodechar{④}{{\libertine{④}}}
\newunicodechar{⑤}{{\libertine{⑤}}}
\newunicodechar{}{{\ubuntu{}}}

%%===============中文化=========%
\renewcommand\figurename{图}
\renewcommand\tablename{表}
\renewcommand{\today}{\number\year 年\number\month 月\number\day 日}
\renewcommand\contentsname{目~录}
\renewcommand\abstractname{摘~要}

%目录
%================目录===============%
%toc label to contents space   dynamic adjust
\RequirePackage{tocloft}%
\renewcommand{\numberline}[1]{%
  \@cftbsnum #1\@cftasnum~\@cftasnumb%
}
\setcounter{tocdepth}{2}

%=======页眉页脚格式=========%
%section格式
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

\pagestyle{headandfoot}

\firstpagefooter{\oddeven{}{\thepage}}{}{\oddeven{\thepage}{}}

\runningfooter{\oddeven{}{\thepage}}{}{\oddeven{\thepage}{}}

\firstpageheader{\raisebox{-12pt}{\includegraphics[scale=0.2]{mandala.pdf}}}
{%\begin{large}
%{\CJKfontspec{颜体}
%\makebox[13em][s]{
%德山学派－回归教育本质}}
%\end{large}
}{\rightmark}

\runningheader{\raisebox{-12pt}{\includegraphics[scale=0.2]{mandala.pdf}}}
{%\begin{large}
%{\CJKfontspec{颜体}
%\makebox[13em][s]{
%德山学派－回归教育本质}}
%\end{large}
}{\rightmark}


\firstpageheadrule
\runningheadrule


%==============超鏈接===============%
\RequirePackage[colorlinks=true,linkcolor=blue,citecolor=blue]{hyperref} %設置書簽和目錄鏈接等
\newcommand{\hlabel}[1]{\phantomsection \label{#1}}%某一小段的引用


%=================文字強調=========%
\RequirePackage{ulem} %下劃線,加點
\normalem%normal em , not instead of the uline

\DeclareRobustCommand*{\uwave}%波浪线稍微下移点。
{\bgroup \markoverwith{\lower5\p@\hbox{\sixly \char58}}\ULon}


\newcommand\reduline{\bgroup\markoverwith
    {\textcolor{red}{\rule[-0.8ex]{1em}{0.4pt}}}\ULon}
\renewcommand\emshape{\color{red}}

%==================插入圖片=======%
\RequirePackage{graphicx}

\graphicspath{{figures/}}

%change the caption style a little like 1-1
%\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}

\newenvironment{fig}[2][1]
        {\begin{figure}[H]
        \centering
        \includegraphics[scale=#1 , keepaspectratio]{#2}}
        {\end{figure}}
\newenvironment{linefig}[2][1]
        {\begin{figure}[H]
        \centering
        \includegraphics[width=#1\linewidth ,totalheight=0.95\textheight , keepaspectratio]{#2}}
        {\end{figure}}


%==============插入表格========%
\RequirePackage{booktabs}
%\renewcommand{\thetable}{\arabic{chapter}-\arabic{table}}
\RequirePackage{caption}
%\renewcommand{\arraystretch}{1.3}
%如果用setspace宏包而不是linespread调整行间距，那么才需要额外的表格行距拉大。

%=============插入尾注=========%
\RequirePackage{endnotes}


%========脚注=========%
\newcommand*\circled[1]{%
  \tikz[baseline=(char.base)]\node[shape=circle,draw,inner sep=0.4pt,minimum size=4pt] (char) {#1};}
\newcommand*\circledarabic[1]{\circled{\arabic{#1}}}

\RequirePackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command

\renewcommand*{\thefootnote}{\protect\circledarabic{footnote}}

\renewcommand\@makefntext[1]
{\vspace{5pt}
\noindent
\makebox[20pt][c]{\@makefnmark}
\fontsize{10pt}{12pt}\selectfont #1}

\setlength{\skip\footins}{20pt plus 10pt}
%main body 与脚注之间的距离

%==========其他宏包===========%
\RequirePackage{chemfig} %化学 同时tikz制图宏包也加载了

%=======列表
\renewcommand{\labelenumi}{(\arabic{enumi})}

%======常用tikz宏包
\usetikzlibrary{calc,shapes,positioning,backgrounds}
\usetikzlibrary{mindmap,trees}

\setlength{\parskip}{1.6ex plus 0.2ex minus 0.2ex}   %段落間距
\setlength{\parindent}{24pt plus 2pt minus 2pt }



%answerline
\setlength{\answerskip}{0pt}
\setlength\answerlinelength{50pt}
\setlength\answerclearance{0ex}%the answer up distance

\RequirePackage{xpatch}% http://ctan.org/pkg/etoolbox
\xpatchcmd{\answerline}% <cmd>
  {\par\nobreak\vskip\answerskip}% <search>
  {}% <replace>
  {}{}% <success><failure>

\xpatchcmd{\answerline}{\fi \par}{\fi}{}{}% Remove line break after \answerline
\xpatchcmd{\answerline}{\fi \hfill}{\fi}{}{}% Remove \hfill

\xpatchcmd{\answerline}{\hrulefill}{\rule[-4pt]{\answerlinelength}{0.4pt}}{}{}%

\LetLtxMacro{\oldanswerline}{\answerline}
\RenewDocumentCommand{\answerline}{s o}{%
  \begingroup
  \IfBooleanTF{#1}
    {\def\@queslevel{\relax}}% \answerline*
    {}% \answerline
  \IfNoValueTF{#2}
    {\oldanswerline[{}]}% \answerline
    {\oldanswerline[#2]}% \answerline[..]
  \endgroup
}


%=======问题格式=======%
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}%remove indentation
%=======选项格式=======%
\renewcommand{\choiceshook}{%
\setlength{\leftmargin}{29.5pt}%
\setlength{\labelwidth}{-\labelsep}%
}

\let\oldoneparchoices\oneparchoices
\def\oneparchoices{\hspace{7.5pt}  \oldoneparchoices }



%其他
\RequirePackage{wallpaper}
\RequirePackage{comment}

\DeclareRobustCommand*{\shortanswerline}{\rule[-2pt]{50pt}{0.4pt}}
\renewcommand{\solutiontitle}{\noindent\textbf{}}

%fillwithlines 命令线高
\setlength\linefillheight{3em}

%answer命令长度调整
\newcommand{\answer}[2][50pt]{{%
\ignorespaces%
\setlength{\answerlinelength}{#1}%
\answerline*[#2]}}



%=========章節標題設計=========%
\RequirePackage{titlesec}
%exam class 没有chapter
\newcommand{\chapter}[1]{\par\begin{LARGE}\sffamily  #1\end{LARGE} \par}
%修改section
\titleformat{\section}{\Large\sffamily}{}{0em}{}
%修改subsection
\titleformat{\subsection}{\large\sffamily}{}{0em}{}
%修改subsubsection
\titleformat{\subsubsection}{\normalsize\sffamily}{}{0em}{}


%===========旁注===========%
\newcommand{\sidenote}[1]{\marginpar{\notefont #1}}


%=====特殊的环境特殊的文字======%
%=========重新定义 quote=====%
\renewenvironment{quote}[1][anonymous]{
\newcommand{\quoteauthor}[1][anonymous]{#1}
\list{}{\rightmargin\leftmargin %右间距等于左间距
\itemindent   2em
}\item\relax
\ttfamily}
{\\
\makebox[\linewidth][r]{\sffamily —\quoteauthor}
\endlist}

%重新定义quotation
\renewenvironment{quotation}
{\list{}{
\itemindent 2em %item的缩进也就是第一段的缩进
\listparindent \itemindent %第二段的缩进
}%
\item\relax
\ttfamily}
{\endlist}


%======notecard环境 一种卡片式记忆环境====%
%长高按照黄金比例分割来，长1，高0.62--0.62\linewidth 0.38\linewidth
%推荐的颜色有：black olive blue orange brown pink cyan purple darkgray red gray teal green violet lightgray white lime magenta yellow 建议都调淡30。!30
%不过推荐一个文档内部一种类型使用一种，其他颜色也是可以的。
\newsavebox{\tempbox}
\newenvironment{notecard}[2][white]
 {\noindent\ignorespaces%
 \setlength{\fboxsep}{10pt}
  \newcommand{\tempcolor}{#1}
  \begin{lrbox}{\tempbox}%
  \begin{minipage}{#2}
        \setlength{\parindent}{0pt}
        \setlength{\parskip}{1.618ex}   %段落間距
}
 {
 \ignorespacesafterend%
  \end{minipage}%
  \end{lrbox}%
  \colorbox{\tempcolor}{\usebox{\tempbox}}}




\endinput


